<template>
    <div class="close_door">
        <top-timer :back="false"/>
        <p class="title font_M font_40 col_333 center">箱门已关闭，请确认入柜衣物是否有误</p>
        <p class="tip col_777 font_30 center">入柜衣物无误，请点击“完成，如有误，请点击“开箱重放”</p>
        <div class="flex btn_group center">
            <!--<el-button class="flex1 col_blue" @click="handleReset()">不洗了</el-button>-->
            <el-button class="flex1 col_blue" @click="handleBack()">开箱重放</el-button>
            <el-button class="flex1 success_btn font_M col_fff" type="primary" @click="handleSuccess()">完成</el-button>
        </div>
        <top-tips/>
    </div>
</template>

<script>
  export default {
    name: 'closed-door',
    methods: {
      handleReset() {
        let boxCode = this.$route.query.boxCode;
        this.$axios.post('laundryRest/openBoxByNotLaundry', {
          boxCode: boxCode,
        }).then(res => {
          if (res.data.result) {
            let success = () => {
              this.$router.push({path: 'NoWashOpenDoor',query:{boxCode:boxCode}});
            };
            let error = () => {
              this.$alert('开箱失败，请联系客服，联系方式见屏幕下方！');
            };
            let boxMac = this.$boxConfig[boxCode];
            window.cordova.plugins.CabinetPlugin.sendOpenBoxCommand(boxMac, success, error);
          } else {
            this.$alert(res.data.msg);
          }
        });

      },
      handleBack() {
        let boxCode = this.$route.query.boxCode;
        let success = () => {
          this.$router.back();
        };
        let error = () => {
          this.$alert('开箱失败，请联系客服，联系方式见屏幕下方！');
        };
        let boxMac = this.$boxConfig[boxCode];
        window.cordova.plugins.CabinetPlugin.sendOpenBoxCommand(boxMac, success, error);
      },
      handleSuccess() {
        let boxCode = this.$route.query.boxCode;
        this.$router.push({path: 'OrderCreated', query: {boxCode: boxCode}});
      },
    },
  };
</script>

<style lang="scss">
    .close_door {
        .title {
            margin: 3.00rem 0 0.20rem;
        }

        .btn_group {
            position: absolute;
            bottom: 1.6rem;
            left: 0;
            right: 0;
            padding: 0 1.40rem;
            flex-wrap: wrap;
            justify-content: space-between;

            button {
                box-shadow: 0rem 0.02rem 0.04rem 0rem rgba(10, 130, 236, 0.2);
                border: 0.02rem solid #0080F4;
                color: #0A82EC;
                border-radius: 2.00rem;
                padding: 0;
                flex: 0 0 2.40rem;
                height: 0.80rem;
                font-size: 0.40rem;
            }

            .success_btn {
                color: white;
                background-color: #0A82EC;
            }
        }
    }
</style>
